$.extend({
    importSubTable: function (subTableCode, subTableFields, data,deptList,userlist) {
        data.forEach(row => {
            $('table[data-datafield="' + subTableCode + '"]+div a:contains("添加")').click();
            var rownum = $('table[data-datafield="' + subTableCode + '"] tr.rows:last').data('row');
            var temp = row.split('|');
            for (var key in subTableFields) {
                //单行文本，多行文本，数字
                if (subTableFields[key].type == '0' || subTableFields[key].type == "string" || typeof (subTableFields[key].type) == "undefined") {
                    $.MvcSheetUI.SetControlValue(key, temp[subTableFields[key].index], rownum);

                } else if (subTableFields[key].type == '1' || subTableFields[key].type == "multiperson") {//多人字段
                    var persons = temp[subTableFields[key].index].split(';');
                    var personArr = [];
                    for (j = 0; j < persons.length; j++) {
                        if (userlist[persons[j]] != null && userlist[persons[j]] != '')
                            personArr.push(userlist[persons[j]]);
                    }
                    $.MvcSheetUI.SetControlValue(key, personArr, Number(rownum));

                } else if (subTableFields[key].type == '2' || subTableFields[key].type == "datetime") {//日期字段
                    $.MvcSheetUI.SetControlValue(key, new Date(temp[subTableFields[key].index]).toLocaleDateString(), Number(rownum));

                } else if (subTableFields[key].type == '3' || subTableFields[key].type == "department") {//部门字段
                    for (j = 0; j < deptList.length; j++) {
                        if (temp[subTableFields[key].index] == deptList[j].Name) {
                            $.MvcSheetUI.SetControlValue(key, deptList[j].ObjectID, Number(rownum));
                            break;
                        }
                    }
                }
            }
        });
    }
});